#include<iostream>
using namespace std;

int chess[100]={0};
int count1 =0;
int abs (int n ){
    return n>0?n:-n;
}

bool isok (int index, int date){
   for(int i =0;i<index;i++){
      if(chess[i]==date||abs(i-index) ==abs(chess[i]-date))
         return false ;
   }
  return true;
}

int findq(int n ,int max){
    if(n==max){
        cout<<++count1<<":";
        for(int i=0; i<max;i++){
            cout<<chess[i]<<",";
        }
        cout<<endl;
        return 0;
    }
    for(int i=0;i<max;i++){
        if(isok(n,i)){
            chess[n]=i;
            findq(n+1,max);
         }
    }

    return 0;
    }

int solve(int max){
    findq(0,max);
    return count1;
    }

int main(){
    cout<<solve(8)<<endl;
    return 0;
}


